﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Moonlite.UI.Shell.Controls
{
    public partial class SplashScreen : Form
    {
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        static public extern IntPtr GetDesktopWindow();
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public extern static IntPtr SetParent(IntPtr hChild, IntPtr hParent);
        private const int WS_EX_TOPMOST = unchecked((int)0x00000008L);
        private const int WS_EX_TOOLWINDOW = unchecked((int)0x00000080);
        private const int CS_DROPSHADOW = 0x00020000;
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams createParams = base.CreateParams;
                createParams.ExStyle |= WS_EX_TOOLWINDOW | WS_EX_TOPMOST | CS_DROPSHADOW;
                createParams.Parent = IntPtr.Zero;
                return createParams;
            }
        }
        protected override void OnHandleCreated(EventArgs e)
        {
            if (Handle != IntPtr.Zero)
            {
                IntPtr hWndDeskTop = GetDesktopWindow();
                SetParent(Handle, hWndDeskTop);
            }
            base.OnHandleCreated(e);
        }
        public new void Show()
        {
            if (Created == false)
            {
                CreateControl();
            }
            Refresh();
            base.Show();
        }
        private static string GetAssemblyCopyright(Assembly assembly)
        {
            object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
            if (attributes.Length == 0)
            {
                return "";
            }
            return ((AssemblyCopyrightAttribute)attributes[0]).Copyright;
        }
        public SplashScreen()
        {
            InitializeComponent();
        }
    }
}
